package Servlet;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class Alert {
	private Alert(){}
	/**
	 * 设置alert相关参数
	 * @param req	request
	 * @param msg	分别是要显示的信息、显示完后要去的目录、字体颜色
	 * 				默认分别为"", index.jsp, red
	 */
	public static void setAlertMsg(HttpServletRequest req, String... msg){
		HttpSession session = req.getSession();
		try{
			session.setAttribute("alert", msg[0]);
			session.setAttribute("alertGoto", msg[1]);
			session.setAttribute("alertColor", msg[2]);
		}catch (Exception e){
			
		}
	}
	
	public static void toAlert(HttpServletResponse res, HttpServletRequest req, String... msg) throws IOException{
		setAlertMsg(req, msg);
		res.sendRedirect("alert.jsp");
	}
}







